<?php
// 导入配置文件 + model类
require './configs/config.php';
// require './models/Model.class.php';

// //导入所有控制器类
// require './controllers/UserController.class.php';
// require './controllers/IndexController.class.php';
// require './controllers/GoodsController.class.php';


//自动加载类  将model+con...都自动加载
function __autoload($classname)
{
	if (file_exists("./models/{$classname}.class.php")) {
		require "./models/{$classname}.class.php";
	} elseif (file_exists("./controllers/{$classname}.class.php")) {
		require "./controllers/{$classname}.class.php";
	} else {
		header("HTTP/1.0 404 not found");
		header("Status:404 not found");//兼容IE
		echo "<h1>404 NOT FOUND</h1>";
		exit();
	}
}

//获取用户的参数
//获取控制器名
$c = (!empty($_GET['c']))?$_GET['c']:'Index';
//获取操作名
$a = (!empty($_GET['a']))?$_GET['a']:'index';

//拼装类名  c为空就是index拼装上Controller
$classname = $c.'Controller';
//实例化控制器  new出来  然后调用
$controller = new $classname();
// var_dump($controller);
//调用方法
$controller->$a();
